class Ability
  include CanCan::Ability

  def initialize(admin_user)
    case admin_user.role
    when 'system_admin'
      can :manage, :all
    when 'human_resource'
      can :manage, Coach
      can :manage, Order
      can :manage, Timetable
      can :manage, Appointment
    when 'super_admin'
      can :manage, Appointment
      can :manage, Timetable
      can :manage, Wallet
      can :manage, Timetables::Provisional
      can :manage, Company
    when 'data_analyst'
      can :manage, Appointment
      can :manage, Order
      can :manage, Timetable
    when 'audit'
      can :manage, Timetable
    end
    can :read, ActiveAdmin::Page, :name => 'Dashboard'
  end
end
